package com.jarveis.frame.jdbc.parser;

import java.io.Serializable;

import com.jarveis.frame.bean.BeanUtil;
import com.jarveis.frame.cache.CacheManager;
import com.jarveis.frame.jdbc.JdbcManager;
import com.jarveis.frame.jdbc.SqlParser;
import com.jarveis.frame.jdbc.ant.TableInfo;

/**
 * 抽象的SQL解析器
 * 
 * @author liuguojun
 */
public abstract class AbstractParser implements SqlParser {

	/**
	 * 获取表信息
	 * 
	 * @param s
	 * @return TableInfo
	 */
	protected TableInfo getTableInfo(Serializable s) {
		String name = BeanUtil.getFname(s);
		TableInfo tableInfo = (TableInfo) CacheManager.getInstance().getCacheValue(
				JdbcManager.CACHE_CORE_TABLE, name);
		if (tableInfo == null) {
			tableInfo = new TableInfo(s);
			CacheManager.getInstance().putCacheValue(JdbcManager.CACHE_CORE_TABLE, name, tableInfo);
		}
		
		return tableInfo;
	}
}
